<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文章栏目列表</title> 
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="/public/admin/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/public/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/admin/css/animate.css" rel="stylesheet">
    <link href="/public/admin/css/style.css?v=4.0.0" rel="stylesheet">

    <!-- 全局js -->
    <script src="/public/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/admin/js/bootstrap.min.js?v=3.3.5"></script>

    <!-- 自定义js -->
    <script src="/public/admin/js/content.js?v=1.0.0"></script>
    <script type="text/javascript" src="/public/admin/js/contabs.js"></script>
    <script type="text/javascript" src="/public/admin/js/common.js"></script>
    <script src="/public/admin/js/plugins/layer/layer.min.js"></script>
    <script type="text/javascript" src="/public/admin/js/article.js"></script>
    <script src="/public/admin/js/myAjax.js"></script>
    <script src="/public/admin/plugins/ckeditor/ckeditor.js"></script>

    <!-- Bootstrap table -->
    <script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/public/admin/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="/public/admin/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <base target="_blank">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>网站模板列表</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="box">
                              <div class="box-header">
                                  <div class="panel-body">
                                    <a onclick="openYemian('/index.php/Admin/System/template','添加网站模板')" href="javascript:;" class="btn btn-primary"><i class="fa fa-plus"></i>新增模板</a>
                                    <a onclick="window.location.href=location.href;" href="javascript:;" class="btn btn-primary pull-left" style="margin-right: 10px;"><i class="glyphicon glyphicon-refresh"></i>刷新</a>
                                  </div>                  
                              </div><!-- /.box-header -->
                           <div class="box-body">
                           <div class="row">
                            <div class="col-sm-12">
                  <table id="list-table" class="table table-bordered" style="text-align: center;">
                     <thead>
                       <tr role="row" >
                           <th>模板名称</th>
                           <th>描述</th>
                           <th>隐藏</th>
                           <th style="width: 100px;">排序</th>
                           <th style="width: 150px;">操作</th>
                       </tr>
                     </thead>
                    <tbody>
                    {if empty($list)}
                        <tr><td colspan="6" style="text-align:center;">暂无数据</td></tr>
                    {/if}
                      {foreach name="list" item="vo" key="k" }
                        <tr role="row" class="{$vo.level}" id="{$vo.level}_{$vo.id}">

                         <td class="sorting_1" align="left">{$vo.template}</td> 
                         <td>{$vo.text_info}</td>
                         <td>{if $vo['is_hide'] == 1}是{else/}否{/if}</td>
                         <td>                         
                            <input type="text"  class="input-sm" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onchange="updateSort('template','id','{$vo.id}','sort',this)" size="4" value="{$vo.sort}" />
                         </td>
                         <td style="text-align: left;">
                          <a class="btn btn-primary" href="javascript:;" onclick="openYemian('/index.php/Admin/System/template/act/edit/id/{$vo.id}','编辑模板')"><i class="fa fa-pencil"></i></a>
                          <a class="btn btn-danger" href="javascript:void(0)" data-url="{:url('System/templateHandle')}" data-id="{$vo.id}" onclick="delcategory('确定删除该模板？此操作不可恢复',{$vo.id},'/index.php/Admin/System/templateHandle',this)"><i class="fa fa-trash-o"></i></a>

                        </td>
                       </tr>
                      {/foreach}
                       </tbody>
                   </table>
                              </div></div>
                                   <div class="row">
                                       <div class="col-sm-5">
                                   </div>
                             </div><!-- /.box-body -->
                           </div><!-- /.box -->
                        </div>
                   </div>
                </div>
            </div>
        </div>
    </div> 
</div>
 
<input id="handle_status" value="" hidden="hidden">

<script type="text/javascript">
     
// 以下是 bootstrap 自带的  js
function rowClicked(obj)
{
  span = obj;

  obj = obj.parentNode.parentNode;

  var tbl = document.getElementById("list-table");

  var lvl = parseInt(obj.className);

  var fnd = false;
  
  var sub_display = $(span).hasClass('glyphicon-minus') ? 'none' : '' ? 'block' : 'table-row' ;
  //console.log(sub_display);
  if(sub_display == 'none'){
      $(span).removeClass('glyphicon-minus btn-info');
      $(span).addClass('glyphicon-plus btn-warning');
  }else{
      $(span).removeClass('glyphicon-plus btn-info');
      $(span).addClass('glyphicon-minus btn-warning');
  }

  for (i = 0; i < tbl.rows.length; i++)
  {
      var row = tbl.rows[i];
      
      if (row == obj)
      {
          fnd = true;         
      }
      else
      {
          if (fnd == true)
          {
              var cur = parseInt(row.className);
              var icon = 'icon_' + row.id;
              if (cur > lvl)
              {
                  row.style.display = sub_display;
                  if (sub_display != 'none')
                  {
                      var iconimg = document.getElementById(icon);
                      $(iconimg).removeClass('glyphicon-plus btn-info');
                      $(iconimg).addClass('glyphicon-minus btn-warning');
                  }else{                    
                      $(iconimg).removeClass('glyphicon-minus btn-info');
                      $(iconimg).addClass('glyphicon-plus btn-warning');
                  }
              }
              else
              {
                  fnd = false;
                  break;
              }
          }
      }
  }

  for (i = 0; i < obj.cells[0].childNodes.length; i++)
  {
      var imgObj = obj.cells[0].childNodes[i];
      if (imgObj.tagName == "IMG")
      {
          if($(imgObj).hasClass('glyphicon-plus btn-info')){
              $(imgObj).removeClass('glyphicon-plus btn-info');
              $(imgObj).addClass('glyphicon-minus btn-warning');
          }else{
              $(imgObj).removeClass('glyphicon-minus btn-warning');
              $(imgObj).addClass('glyphicon-plus btn-info');
          }
      }
  }

}

function delfun(obj){
    if(confirm('确认删除')){        
        $.ajax({
            type : 'post',
            url : $(obj).attr('data-url'),
            data : {act:'del',cat_id:$(obj).attr('data-id')},
            dataType : 'json',
            success : function(data){
                if(data==1){
                    $(obj).parent().parent().remove();
                }else{
                    layer.alert(data, {icon: 2});  //alert(data);
                }
            }
        })
    }
    return false;
}
function delcategory(name,id,url,obj) {
    top.layer.confirm(name,{
        icon:3,
        btn:['确定','取消'],
    } , function(){
        $.ajax({
            url : url,
            type : "post",
            data : {id:id,act:'del'},
            dataType : "json",
            success:function(data){
                if (data.status == 1) { 
                    top.layer.msg(data.message);
                    $(obj).parent().parent().remove();
                } else {
                    top.layer.msg(data.message);
                }
            }
        });
    } , function(){
        layer.close(); //再执行关闭 
    })
}
</script>

</body>
</html>